/*
=======================================================================

  BOTS UI Console Commands

=======================================================================
*/
#include "ui_local.h"
#include "ui_BOTS.h"

// We need a global here so that the callback routine 
// knows what class we want.  
//
// I know... I know... it's
// completely ugly, but I'm not sure if we can pass
// parameters to the callback.
int GlobalCurrentClass;
int GlobalCurrentLevel;

int BOTS_GetClassLevel() {
	return GlobalCurrentLevel;
}

int BOTS_GetClassType(){
	return GlobalCurrentClass;
}

qboolean BOTS_UI_ConsoleCommands(char* cmd)
{
	uiClientState_t	cs;
	char info[MAX_INFO_STRING];

	// get the class type
	trap_GetClientState( &cs );
	trap_GetConfigString( CS_BOTS_CLIENT + cs.clientNum, info, MAX_INFO_STRING );
	GlobalCurrentClass  = atoi(Info_ValueForKey(  info, "c" ));
	GlobalCurrentLevel = atoi(Info_ValueForKey(info, "lev"));

/////////////////////////////////////////////
// BOTS Main Menu - all classes
//
// Semi-generic menu all classes see when they
// type 'menu' at the console.  It will be
// tailored to their class.
//
	if (Q_stricmp (cmd, "menu") == 0 )
	{
		if (GlobalCurrentClass == 0)
			BOTS_TeamJoinMenu_f();
		else
			BOTS_MainMenu_f();
		return qtrue;
	}

/////////////////////////////////////////////
// The following are called from CG_ServerCommand in cg_servercmds.c.
// It is a direct result of a trap_SendServerCommand in 
// BOTSg_ConsoleCommands.c - the order is important in order to
// create the proper data lists that each menu depends on.
//
	// BOTS class menu
	else if (Q_stricmp (cmd, "UI_show_class_menu") == 0 ) 
	{
		BOTS_ClassJoinMenu_f();
		return qtrue;
	}

	// BOTS team join menu
	else if ( Q_stricmp (cmd, "UI_show_rejoin_menu") == 0 )
	{
		BOTS_TeamJoinMenu_f();
		return qtrue;
	}

	// BOTS Create Menu
	else if ( Q_stricmp (cmd, "UI_show_create_menu") == 0 )
	{
		if (GlobalCurrentClass == BOTS_SCIENTIST || GlobalCurrentClass == BOTS_NURSE)
			BOTS_CreateMenu_f(GlobalCurrentClass);
		return qtrue;
	}

	// BOTS Infiltrator Disguise Menu
	else if ( Q_stricmp (cmd, "UI_show_disguise_menu") == 0 )
	{
		BOTS_InfiltratorDisguiseMenu_f();
		return qtrue;
	}

	// BOTS Scientist General Research Menu
	else if ( Q_stricmp (cmd, "UI_show_genresearch_menu") == 0 )
	{
		BOTS_ScientistGenResearchMenu_f();
		return qtrue;
	}
	else if ( Q_stricmp (cmd, "UI_show_classresearch_menu") == 0 )
	{
		BOTS_ScientistResearchClassMenu_f();
		return qtrue;
	}

	/////////////////////////////////////////////


	// BOTS Map Vote Menu
	else if ( Q_stricmp (cmd, "UI_show_mapvote_menu") == 0 )
	{
		BOTS_AddItemsToMenu_f(BOTS_ITEM_MENU_MAPVOTE_E);
		return qtrue;
	}

	// BOTS Vote Menu
	else if ( Q_stricmp (cmd, "UI_show_vote_menu") == 0 )
	{
		BOTS_AddItemsToMenu_f(BOTS_ITEM_MENU_VOTE_E);
		return qtrue;
	}

	// BOTS Mute Menu
	else if ( Q_stricmp (cmd, "UI_show_mute_menu") == 0 )
	{
		BOTS_AddItemsToMenu_f(BOTS_ITEM_MENU_MUTE_E);
		return qtrue;
	}

	// BOTS Unmute Menu
	else if ( Q_stricmp (cmd, "UI_show_unmute_menu") == 0 )
	{
		BOTS_AddItemsToMenu_f(BOTS_ITEM_MENU_UMUTE_E);
		return qtrue;
	}

	// BOTS Captain Promote Menu
	else if ( Q_stricmp (cmd, "UI_show_promote_menu") == 0 )
	{
		BOTS_AddItemsToMenu_f(BOTS_ITEM_MENU_PROMOTE_E);
		return qtrue;
	}
	else if ( Q_stricmp (cmd, "UI_show_demote_menu") == 0 )
	{
		BOTS_AddItemsToMenu_f(BOTS_ITEM_MENU_DEMOTE_E);
		return qtrue;
	}

	// BOTS Captain Video Menu
	else if ( Q_stricmp (cmd, "UI_show_video_menu") == 0 )
	{
		BOTS_AddItemsToMenu_f(BOTS_ITEM_MENU_VIDEO_E);
		return qtrue;
	}
	
	// BOTS Nurse Heal Menu 
	else if ( Q_stricmp (cmd, "UI_show_heal_menu") == 0 )
	{
		BOTS_AddItemsToMenu_f(BOTS_ITEM_MENU_HEAL_E);
		return qtrue;
	}
//
// End special list creation menus
/////////////////////////////////////////////

	else if ( Q_stricmp (cmd, "ui_teamOrders") == 0 ) 
	{
		if (GlobalCurrentClass == BOTS_CAPTAIN || GlobalCurrentClass == BOTS_SCIENTIST)
			UI_TeamOrdersMenu_f();

		return qtrue;
	}

	else
		return qfalse;
}
